﻿using System;

namespace RexToy.UI.Controls
{
    public class TableCell : Container
    {

        internal TableCell(System.Html.DOM.Td domCell)
        {
            __dragEventBubble = false;
            this.__domNode = new RexToy.UI.Controls.DomNode(domCell);
        }

        public override void AppendControl(Control ctrl)
        {
            ctrl.Init();
            this.__domNode.AppendChild(ctrl.DomNode);
            this.__controls.Push(ctrl);
        }

        public override void RemoveControl(Control ctrl)
        {
            this.__domNode.RemoveChild(ctrl.DomNode);
            this.__controls.Remove(ctrl);
        }

        public uint ColSpan
        {
            get
            {
                var td = this.__domNode._element as System.Html.DOM.Td;
                return td.ColSpan;
            }
            set
            {
                var td = this.__domNode._element as System.Html.DOM.Td;
                td.ColSpan = value;
            }
        }

        public uint RowSpan
        {
            get
            {
                var td = this.__domNode._element as System.Html.DOM.Td;
                return td.RowSpan;
            }
            set
            {
                var td = this.__domNode._element as System.Html.DOM.Td;
                td.RowSpan = value;
            }
        }
    }
}
